package world.liuru.poem.service.impl;

import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import world.liuru.poem.entity.Consumer;
import world.liuru.poem.repository.ConsumerRepository;
import world.liuru.poem.service.ConsumerService;

import javax.annotation.Resource;
import java.util.Optional;
@Service
public class ConsumerServiceImpl implements ConsumerService {

    @Resource
    ConsumerRepository consumerRepository;
    @Override
    public Consumer getConsumer(String name, String password) {
        Consumer consumer = new Consumer();
        consumer.setName(name);
        consumer.setPassword(password);
        Example<Consumer> example = Example.of(consumer);
        Optional<Consumer> one = consumerRepository.findOne(example);
        return one.orElse(null);
    }

}
